package com.yzy.soft.system.freemarker.template;

import com.yzy.soft.system.freemarker.*;
import com.yzy.soft.system.freemarker.database.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class TemplateMapperXML extends TemplateKernel {

    private final static Logger logger=LoggerFactory.getLogger(TemplateMapperXML.class);

    @Override
    public File generateFileType(FileInfo fileInfo,Table table, DBInfo dbInfo) throws Exception {
        JavaFileMapperXml javaFile=((JavaFile)fileInfo).getJavaFileMapperXml();
        final String suffix = "Mapper.xml";
        final String templateName = "MapperXML.ftl";
        String tableName = javaFile.getFilename();
        final String path = fileInfo.getDiskPath() + tableName + javaFile.getSuffix();
        System.out.println("TemplateMapperXML path:"+path);
        Map<String, Object> dataMap = new HashMap<String, Object>();
            dataMap.put("mapperXML_tablename", tableName);
            dataMap.put("mapperXML_packageName", javaFile.getPackageName());
            File file = new File(path);
        if (!file.exists()) {
            file.createNewFile();
        }
        generateFileByTemplate(templateName, file, fileInfo,dataMap);
        return file;
    }




}
